﻿using System;
using System.Collections.Generic;
using SharpSqlAnalyzer.nodes;
using SharpSqlAnalyzer.nodes.hive;
using SharpSqlAnalyzer.nodes.teradata;

namespace SharpSqlAnalyzer.stmt
{
	// Token: 0x0200009A RID: 154
	public class TCreateTableSqlStatement : TCustomSqlStatement
	{
		// Token: 0x17000097 RID: 151
		// (get) Token: 0x0600046F RID: 1135 RVA: 0x002FB4FE File Offset: 0x002F96FE
		// (set) Token: 0x06000470 RID: 1136 RVA: 0x002FB506 File Offset: 0x002F9706
		public List<TCreateTableOption> TableOptions
		{
			get
			{
				return this._tableOptions;
			}
			set
			{
				this._tableOptions = value;
			}
		}

		// Token: 0x17000098 RID: 152
		// (get) Token: 0x06000472 RID: 1138 RVA: 0x002FB518 File Offset: 0x002F9718
		// (set) Token: 0x06000471 RID: 1137 RVA: 0x002FB50F File Offset: 0x002F970F
		public TSourceToken stGlobal
		{
			get
			{
				return this._stGlobal;
			}
			set
			{
				this._stGlobal = value;
			}
		}

		// Token: 0x17000099 RID: 153
		// (get) Token: 0x06000474 RID: 1140 RVA: 0x002FB529 File Offset: 0x002F9729
		// (set) Token: 0x06000473 RID: 1139 RVA: 0x002FB520 File Offset: 0x002F9720
		public TSourceToken stLocal
		{
			get
			{
				return this._stLocal;
			}
			set
			{
				this._stLocal = value;
			}
		}

		// Token: 0x1700009A RID: 154
		// (get) Token: 0x06000476 RID: 1142 RVA: 0x002FB53A File Offset: 0x002F973A
		// (set) Token: 0x06000475 RID: 1141 RVA: 0x002FB531 File Offset: 0x002F9731
		public TSourceToken stTemporary
		{
			get
			{
				return this._stTemporary;
			}
			set
			{
				this._stTemporary = value;
			}
		}

		// Token: 0x1700009B RID: 155
		// (get) Token: 0x06000478 RID: 1144 RVA: 0x002FB54B File Offset: 0x002F974B
		// (set) Token: 0x06000477 RID: 1143 RVA: 0x002FB542 File Offset: 0x002F9742
		public TSourceToken stTemp
		{
			get
			{
				return this._stTemp;
			}
			set
			{
				this._stTemp = value;
			}
		}

		// Token: 0x1700009C RID: 156
		// (get) Token: 0x06000479 RID: 1145 RVA: 0x002FB553 File Offset: 0x002F9753
		// (set) Token: 0x0600047A RID: 1146 RVA: 0x002FB55B File Offset: 0x002F975B
		public virtual TTable AsTable
		{
			get
			{
				return this.asTable;
			}
			set
			{
				this.asTable = value;
			}
		}

		// Token: 0x1700009D RID: 157
		// (get) Token: 0x0600047B RID: 1147 RVA: 0x002FB564 File Offset: 0x002F9764
		// (set) Token: 0x0600047C RID: 1148 RVA: 0x002FB56C File Offset: 0x002F976C
		public virtual bool ExternalTable
		{
			get
			{
				return this.externalTable;
			}
			set
			{
				this.externalTable = value;
			}
		}

		// Token: 0x1700009E RID: 158
		// (get) Token: 0x0600047D RID: 1149 RVA: 0x002FB575 File Offset: 0x002F9775
		// (set) Token: 0x0600047E RID: 1150 RVA: 0x002FB57D File Offset: 0x002F977D
		public virtual List<TIndexDefinition> IndexDefinitions
		{
			get
			{
				return this.indexDefinitions;
			}
			set
			{
				this.indexDefinitions = value;
			}
		}

		// Token: 0x1700009F RID: 159
		// (get) Token: 0x0600047F RID: 1151 RVA: 0x002FB586 File Offset: 0x002F9786
		// (set) Token: 0x06000480 RID: 1152 RVA: 0x002FB58E File Offset: 0x002F978E
		public virtual bool External
		{
			get
			{
				return this.external;
			}
			set
			{
				this.external = value;
			}
		}

		// Token: 0x170000A0 RID: 160
		// (get) Token: 0x06000481 RID: 1153 RVA: 0x002FB597 File Offset: 0x002F9797
		// (set) Token: 0x06000482 RID: 1154 RVA: 0x002FB59F File Offset: 0x002F979F
		public virtual THiveRowFormat HiveRowFormat
		{
			get
			{
				return this.hiveRowFormat;
			}
			set
			{
				this.hiveRowFormat = value;
			}
		}

		// Token: 0x170000A1 RID: 161
		// (get) Token: 0x06000483 RID: 1155 RVA: 0x002FB5A8 File Offset: 0x002F97A8
		// (set) Token: 0x06000484 RID: 1156 RVA: 0x002FB5B0 File Offset: 0x002F97B0
		public virtual THiveTableBuckets HiveTableBuckets
		{
			get
			{
				return this.hiveTableBuckets;
			}
			set
			{
				this.hiveTableBuckets = value;
			}
		}

		// Token: 0x170000A2 RID: 162
		// (get) Token: 0x06000485 RID: 1157 RVA: 0x002FB5B9 File Offset: 0x002F97B9
		// (set) Token: 0x06000486 RID: 1158 RVA: 0x002FB5C1 File Offset: 0x002F97C1
		public virtual THiveTableFileFormat HiveTableFileFormat
		{
			get
			{
				return this.hiveTableFileFormat;
			}
			set
			{
				this.hiveTableFileFormat = value;
			}
		}

		// Token: 0x170000A3 RID: 163
		// (get) Token: 0x06000487 RID: 1159 RVA: 0x002FB5CA File Offset: 0x002F97CA
		// (set) Token: 0x06000488 RID: 1160 RVA: 0x002FB5D2 File Offset: 0x002F97D2
		public virtual THiveTablePartition HiveTablePartition
		{
			get
			{
				return this.hiveTablePartition;
			}
			set
			{
				this.hiveTablePartition = value;
			}
		}

		// Token: 0x170000A4 RID: 164
		// (get) Token: 0x06000489 RID: 1161 RVA: 0x002FB5DB File Offset: 0x002F97DB
		// (set) Token: 0x0600048A RID: 1162 RVA: 0x002FB5E3 File Offset: 0x002F97E3
		public virtual THiveTableProperties HiveTableProperties
		{
			get
			{
				return this.hiveTableProperties;
			}
			set
			{
				this.hiveTableProperties = value;
			}
		}

		// Token: 0x170000A5 RID: 165
		// (get) Token: 0x0600048B RID: 1163 RVA: 0x002FB5EC File Offset: 0x002F97EC
		// (set) Token: 0x0600048C RID: 1164 RVA: 0x002FB5F4 File Offset: 0x002F97F4
		public virtual THiveTableSkewed HiveTableSkewed
		{
			get
			{
				return this.hiveTableSkewed;
			}
			set
			{
				this.hiveTableSkewed = value;
			}
		}

		// Token: 0x170000A6 RID: 166
		// (get) Token: 0x0600048D RID: 1165 RVA: 0x002FB5FD File Offset: 0x002F97FD
		// (set) Token: 0x0600048E RID: 1166 RVA: 0x002FB605 File Offset: 0x002F9805
		public virtual bool IfNotExists
		{
			get
			{
				return this.ifNotExists;
			}
			set
			{
				this.ifNotExists = value;
			}
		}

		// Token: 0x170000A7 RID: 167
		// (get) Token: 0x0600048F RID: 1167 RVA: 0x002FB60E File Offset: 0x002F980E
		// (set) Token: 0x06000490 RID: 1168 RVA: 0x002FB616 File Offset: 0x002F9816
		public virtual TObjectName LikeTableName
		{
			get
			{
				return this.likeTableName;
			}
			set
			{
				this.likeTableName = value;
			}
		}

		// Token: 0x170000A8 RID: 168
		// (get) Token: 0x06000491 RID: 1169 RVA: 0x002FB61F File Offset: 0x002F981F
		// (set) Token: 0x06000492 RID: 1170 RVA: 0x002FB627 File Offset: 0x002F9827
		public virtual TObjectName TableComment
		{
			get
			{
				return this.tableComment;
			}
			set
			{
				this.tableComment = value;
			}
		}

		// Token: 0x170000A9 RID: 169
		// (get) Token: 0x06000493 RID: 1171 RVA: 0x002FB630 File Offset: 0x002F9830
		// (set) Token: 0x06000494 RID: 1172 RVA: 0x002FB638 File Offset: 0x002F9838
		public virtual TObjectName TableLocation
		{
			get
			{
				return this.tableLocation;
			}
			set
			{
				this.tableLocation = value;
			}
		}

		// Token: 0x170000AA RID: 170
		// (get) Token: 0x06000495 RID: 1173 RVA: 0x002FB641 File Offset: 0x002F9841
		// (set) Token: 0x06000496 RID: 1174 RVA: 0x002FB649 File Offset: 0x002F9849
		public virtual TObjectName RowTypeName
		{
			get
			{
				return this.rowTypeName;
			}
			set
			{
				this.rowTypeName = value;
			}
		}

		// Token: 0x170000AB RID: 171
		// (get) Token: 0x06000497 RID: 1175 RVA: 0x002FB652 File Offset: 0x002F9852
		// (set) Token: 0x06000498 RID: 1176 RVA: 0x002FB65A File Offset: 0x002F985A
		public virtual TObjectName SuperTableName
		{
			get
			{
				return this.superTableName;
			}
			set
			{
				this.superTableName = value;
			}
		}

		// Token: 0x170000AC RID: 172
		// (get) Token: 0x06000499 RID: 1177 RVA: 0x002FB663 File Offset: 0x002F9863
		// (set) Token: 0x0600049A RID: 1178 RVA: 0x002FB66B File Offset: 0x002F986B
		public virtual TSelectSqlStatement SubQuery
		{
			get
			{
				return this.subQuery;
			}
			set
			{
				this.subQuery = value;
			}
		}

		// Token: 0x170000AD RID: 173
		// (get) Token: 0x0600049B RID: 1179 RVA: 0x002FB674 File Offset: 0x002F9874
		// (set) Token: 0x0600049C RID: 1180 RVA: 0x002FB67C File Offset: 0x002F987C
		public virtual TExecutePreparedStatement ExecutePreparedStatement
		{
			get
			{
				return this.executePreparedStatement;
			}
			set
			{
				this.executePreparedStatement = value;
			}
		}

		// Token: 0x170000AE RID: 174
		// (get) Token: 0x0600049D RID: 1181 RVA: 0x002FB685 File Offset: 0x002F9885
		// (set) Token: 0x0600049E RID: 1182 RVA: 0x002FB68D File Offset: 0x002F988D
		public virtual List<TMySQLCreateTableOption> MySQLTableOptionList
		{
			get
			{
				return this.mySQLTableOptionList;
			}
			set
			{
				this.mySQLTableOptionList = value;
			}
		}

		// Token: 0x0600049F RID: 1183 RVA: 0x002FB696 File Offset: 0x002F9896
		public TCreateTableSqlStatement(EDbVendor dbvendor) : base(dbvendor)
		{
			this.sqlstatementtype = ESqlStatementType.sstcreatetable;
		}

		// Token: 0x060004A0 RID: 1184 RVA: 0x002FB6A6 File Offset: 0x002F98A6
		internal override void buildsql()
		{
		}

		// Token: 0x060004A1 RID: 1185 RVA: 0x002FB6A8 File Offset: 0x002F98A8
		internal override void clear()
		{
		}

		// Token: 0x060004A2 RID: 1186 RVA: 0x002FB6AA File Offset: 0x002F98AA
		internal override string getasprettytext()
		{
			return "";
		}

		// Token: 0x060004A3 RID: 1187 RVA: 0x002FB6B1 File Offset: 0x002F98B1
		internal virtual void iterate(TVisitorAbs pvisitor)
		{
		}

		// Token: 0x170000AF RID: 175
		// (get) Token: 0x060004A4 RID: 1188 RVA: 0x002FB6B3 File Offset: 0x002F98B3
		// (set) Token: 0x060004A5 RID: 1189 RVA: 0x002FB6C6 File Offset: 0x002F98C6
		public virtual TObjectName TableName
		{
			get
			{
				return this.tables.getTable(0).TableName;
			}
			set
			{
				this.tableName = value;
			}
		}

		// Token: 0x060004A6 RID: 1190 RVA: 0x002FB6D0 File Offset: 0x002F98D0
		public override int doParseStatement(TCustomSqlStatement psql)
		{
			if (this.rootNode == null)
			{
				return -1;
			}
			TCreateTableSqlNode tcreateTableSqlNode = (TCreateTableSqlNode)this.rootNode;
			base.doParseStatement(psql);
			this.TargetTable = tcreateTableSqlNode.Table;
			if (tcreateTableSqlNode.globalLocalTemp != null)
			{
				TSourceToken tsourceToken = tcreateTableSqlNode.globalLocalTemp.st1;
				if (string.Compare(tsourceToken.astext.ToUpper(), "GLOBAL") == 0)
				{
					this._stGlobal = tsourceToken;
				}
				else if (string.Compare(tsourceToken.astext.ToUpper(), "LOCAL") == 0)
				{
					this._stLocal = tsourceToken;
				}
				else if (string.Compare(tsourceToken.astext.ToUpper(), "TEMP") == 0)
				{
					this._stTemp = tsourceToken;
				}
				else if (string.Compare(tsourceToken.astext.ToUpper(), "TEMPORARY") == 0)
				{
					this._stTemporary = tsourceToken;
				}
				tsourceToken = tcreateTableSqlNode.globalLocalTemp.st2;
				if (tsourceToken != null)
				{
					if (string.Compare(tsourceToken.astext.ToUpper(), "GLOBAL") == 0)
					{
						this._stGlobal = tsourceToken;
					}
					else if (string.Compare(tsourceToken.astext.ToUpper(), "LOCAL") == 0)
					{
						this._stLocal = tsourceToken;
					}
					else if (string.Compare(tsourceToken.astext.ToUpper(), "TEMP") == 0)
					{
						this._stTemp = tsourceToken;
					}
					else if (string.Compare(tsourceToken.astext.ToUpper(), "TEMPORARY") == 0)
					{
						this._stTemporary = tsourceToken;
					}
				}
			}
			this.externalTable = tcreateTableSqlNode.ExternalTable;
			this.mySQLTableOptionList = tcreateTableSqlNode.MySQLTableOptionList;
			this._tableOptions = tcreateTableSqlNode.TableOptions;
			if (this._tableOptions != null)
			{
				for (int i = 0; i < this._tableOptions.Count; i++)
				{
					this._tableOptions[i].doParse(this, ESqlClause.unknown);
				}
			}
			this.superTableName = tcreateTableSqlNode.SuperTableName;
			this.rowTypeName = tcreateTableSqlNode.RowTypeName;
			this.tables.addTable(tcreateTableSqlNode.Table);
			this.asTable = tcreateTableSqlNode.AsTable;
			if (this.asTable != null)
			{
				this.tables.addTable(this.asTable);
			}
			if (tcreateTableSqlNode.TableElementList != null && tcreateTableSqlNode.TableElementList.size() > 0)
			{
				for (int j = 0; j < tcreateTableSqlNode.TableElementList.size(); j++)
				{
					TTableElement tableElement = tcreateTableSqlNode.TableElementList.getTableElement(j);
					if (tableElement.Type == 1)
					{
						this.ColumnList.addColumn(tableElement.ColumnDefinition);
						TColumnDefinition columnDefinition = tableElement.ColumnDefinition;
						columnDefinition.doParse(this, ESqlClause.createTable);
						this.TargetTable.ObjectNameReferences.addObjectName(columnDefinition.ColumnName);
						columnDefinition.ColumnName.Location = ESqlClause.createTable;
						columnDefinition.ColumnName.linkedColumnDefinition = columnDefinition;
						this.TargetTable.LinkedColumns.addObjectName(columnDefinition.ColumnName);
						columnDefinition.ColumnName.SourceTable = this.TargetTable;
					}
					else if (tableElement.Type != 3 && tableElement.Type != 4)
					{
						tableElement.Constraint.doParse(this, ESqlClause.unknown);
						this.TableConstraints.addConstraint(tableElement.Constraint);
					}
				}
			}
			if (tcreateTableSqlNode.ColumnList != null && tcreateTableSqlNode.ColumnList.size() > 0)
			{
				for (int k = 0; k < tcreateTableSqlNode.ColumnList.size(); k++)
				{
					TColumnDefinition tcolumnDefinition = new TColumnDefinition(tcreateTableSqlNode.ColumnList.getObjectName(k));
					tcolumnDefinition.startToken = tcolumnDefinition.ColumnName.startToken;
					tcolumnDefinition.endToken = tcolumnDefinition.ColumnName.endToken;
					this.ColumnList.addColumn(tcolumnDefinition);
					this.TargetTable.ObjectNameReferences.addObjectName(tcreateTableSqlNode.ColumnList.getObjectName(k));
					this.TargetTable.LinkedColumns.addObjectName(tcreateTableSqlNode.ColumnList.getObjectName(k));
					tcreateTableSqlNode.ColumnList.getObjectName(k).SourceTable = this.TargetTable;
				}
			}
			if (this.subQuery == null && tcreateTableSqlNode.SubQueryNode != null)
			{
				this.subQuery = new TSelectSqlStatement(this.dbvendor);
				this.subQuery.rootNode = tcreateTableSqlNode.SubQueryNode;
				this.subQuery.doParseStatement(this);
			}
			if (tcreateTableSqlNode.ExecuteSqlNode != null)
			{
				this.executePreparedStatement = new TExecutePreparedStatement(this.dbvendor);
				this.executePreparedStatement.rootNode = tcreateTableSqlNode.ExecuteSqlNode;
				this.executePreparedStatement.doParseStatement(this);
			}
			this.external = tcreateTableSqlNode.External;
			this.ifNotExists = tcreateTableSqlNode.IfNotExists;
			if (tcreateTableSqlNode.TableComment != null)
			{
				this.tableComment = tcreateTableSqlNode.TableComment;
			}
			this.tableLocation = tcreateTableSqlNode.TableLocation;
			this.hiveTableProperties = tcreateTableSqlNode.HiveTableProperties;
			this.hiveTablePartition = tcreateTableSqlNode.HiveTablePartition;
			this.hiveTableBuckets = tcreateTableSqlNode.HiveTableBuckets;
			this.hiveRowFormat = tcreateTableSqlNode.HiveRowFormat;
			this.hiveTableSkewed = tcreateTableSqlNode.HiveTableSkewed;
			this.hiveTableFileFormat = tcreateTableSqlNode.HiveTableFileFormat;
			this.likeTableName = tcreateTableSqlNode.LikeTableName;
			this.indexDefinitions = tcreateTableSqlNode.IndexDefinitions;
			return 0;
		}

		// Token: 0x170000B0 RID: 176
		// (get) Token: 0x060004A7 RID: 1191 RVA: 0x002FBBBB File Offset: 0x002F9DBB
		// (set) Token: 0x060004A8 RID: 1192 RVA: 0x002FBBD6 File Offset: 0x002F9DD6
		public virtual TConstraintList TableConstraints
		{
			get
			{
				if (this.tableConstraints == null)
				{
					this.tableConstraints = new TConstraintList();
				}
				return this.tableConstraints;
			}
			set
			{
				this.tableConstraints = value;
			}
		}

		// Token: 0x170000B1 RID: 177
		// (get) Token: 0x060004A9 RID: 1193 RVA: 0x002FBBDF File Offset: 0x002F9DDF
		// (set) Token: 0x060004AA RID: 1194 RVA: 0x002FBBFA File Offset: 0x002F9DFA
		public virtual TColumnDefinitionList ColumnList
		{
			get
			{
				if (this.columnList == null)
				{
					this.columnList = new TColumnDefinitionList();
				}
				return this.columnList;
			}
			set
			{
				this.columnList = value;
			}
		}

		// Token: 0x060004AB RID: 1195 RVA: 0x002FBC03 File Offset: 0x002F9E03
		public override void accept(TParseTreeVisitor v)
		{
			v.preVisit(this);
			v.postVisit(this);
		}

		// Token: 0x060004AC RID: 1196 RVA: 0x002FBC14 File Offset: 0x002F9E14
		public override void acceptChildren(TParseTreeVisitor v)
		{
			v.preVisit(this);
			this.ColumnList.acceptChildren(v);
			if (this.TableConstraints != null && this.TableConstraints.size() > 0)
			{
				this.TableConstraints.acceptChildren(v);
			}
			if (this.SubQuery != null)
			{
				this.SubQuery.acceptChildren(v);
			}
			v.postVisit(this);
		}

		// Token: 0x040010F6 RID: 4342
		private List<TCreateTableOption> _tableOptions;

		// Token: 0x040010F7 RID: 4343
		private TSourceToken _stGlobal;

		// Token: 0x040010F8 RID: 4344
		private TSourceToken _stLocal;

		// Token: 0x040010F9 RID: 4345
		private TSourceToken _stTemporary;

		// Token: 0x040010FA RID: 4346
		private TSourceToken _stTemp;

		// Token: 0x040010FB RID: 4347
		private TTable asTable;

		// Token: 0x040010FC RID: 4348
		private bool externalTable;

		// Token: 0x040010FD RID: 4349
		private List<TIndexDefinition> indexDefinitions;

		// Token: 0x040010FE RID: 4350
		private bool external;

		// Token: 0x040010FF RID: 4351
		private bool ifNotExists;

		// Token: 0x04001100 RID: 4352
		private TObjectName tableLocation;

		// Token: 0x04001101 RID: 4353
		private TObjectName tableComment;

		// Token: 0x04001102 RID: 4354
		private THiveTableProperties hiveTableProperties;

		// Token: 0x04001103 RID: 4355
		private THiveTablePartition hiveTablePartition;

		// Token: 0x04001104 RID: 4356
		private THiveTableBuckets hiveTableBuckets;

		// Token: 0x04001105 RID: 4357
		private THiveTableSkewed hiveTableSkewed;

		// Token: 0x04001106 RID: 4358
		private THiveRowFormat hiveRowFormat;

		// Token: 0x04001107 RID: 4359
		private THiveTableFileFormat hiveTableFileFormat;

		// Token: 0x04001108 RID: 4360
		private TObjectName likeTableName;

		// Token: 0x04001109 RID: 4361
		private TObjectName rowTypeName;

		// Token: 0x0400110A RID: 4362
		private TObjectName superTableName;

		// Token: 0x0400110B RID: 4363
		private TSelectSqlStatement subQuery;

		// Token: 0x0400110C RID: 4364
		private TExecutePreparedStatement executePreparedStatement;

		// Token: 0x0400110D RID: 4365
		private List<TMySQLCreateTableOption> mySQLTableOptionList;

		// Token: 0x0400110E RID: 4366
		private TObjectName tableName;

		// Token: 0x0400110F RID: 4367
		private TColumnDefinitionList columnList;

		// Token: 0x04001110 RID: 4368
		private TConstraintList tableConstraints;
	}
}
